﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
namespace Entity
{
    public  class LUONGCB
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        private String MALUONGCB, MAGV;
        private float TONGHESOLUONG, TONGLUONGCB;
        private int NAMHOC, HOCKI;

        public String maluongcb
        {
            get { return MALUONGCB; }
            set { MALUONGCB = value; }
        }

        public String magv
        {
            get { return MAGV; }
            set { MAGV = value; }
        }

        public int hocki
        {
            get { return HOCKI; }
            set { HOCKI = value; }
        }

        public int namhoc
        {
            get { return NAMHOC; }
            set { NAMHOC = value; }
        }

        public float tonghesoluong
        {
            get { return TONGHESOLUONG; }
            set { TONGHESOLUONG = value; }
        }

        public float luongcb
        {
            get { return TONGLUONGCB; }
            set { TONGLUONGCB = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dtgLuongCB"></param>

        public void hienthi_LuongCB(DataGridView dtgLuongCB)
        {
            String excuteString = "SELECT * FROM BANGLUONGCB";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgLuongCB.DataSource = dataTable;
        }

        public void xoa_LuongCB(String maluongCB)
        {
            String excuteString = "DELETE FROM BANGLUONGCB WHERE MALUONGCB='" + maluongCB + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void them_LuongCB(LUONGCB luongCB)
        {
            String excuteString = "INSERT INTO BANGLUONGCB VALUES('"+ luongCB.maluongcb + "','"
                                                               + luongCB.magv + "',"
                                                               + luongCB.tonghesoluong + ","
                                                               + luongCB.luongcb + ","
                                                               + luongCB.hocki + ","
                                                               + luongCB.namhoc + ")";
                                                               
                                                              
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_LuongCB(LUONGCB luongCB)
        {
            String excuteString = "UPDATE BANGLUONGCB SET MAGV='" + luongCB.magv +
                                                  "',TONGHESOLUONG =" + luongCB.tonghesoluong +
                                                  ",TONGLUONGCB =" + luongCB.luongcb +
                                                  ",HOCKI =" + luongCB.hocki +
                                                  ",NAMHOC =" + luongCB.namhoc +
                                                  " WHERE MALUONGCB='" + luongCB.maluongcb + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }
    }
}
